home *** CD-ROM | disk | FTP | other *** search
- #
- # Sample script demonstrating keyboard input and logical action.
- # For CD Shell 2.0, Feb 2003
- #
-
-
- #--------------------------------------------------------------------------
- # Standard stuff...
- start: cls
- print "\n\n"
- print "Try pressing A, m, 9, tab, backspace, Ctrl-F4, F3, enter, "
- print "or escape (to quit).\n\n"
-
-
- #--------------------------------------------------------------------------
- # If no key is pressed in 5 seconds, we pretend the escape key was pressed.
-
- getkey 5 set lastKey = key[esc]
-
-
- #--------------------------------------------------------------------------
- # Keys use the key[] function, which returns the keycode of that
- # key so that it may be compared with $lastKey
- #
- # You could also do some fancy stuff here like:
- # if $lastKey == key[B] || $lastKey == key[home]; then <blah, blah>
-
- if $lastKey == key[A]; then print "A pressed."; then goto wait
- if $lastKey == key[m]; then print "m pressed."; then goto wait
- if $lastKey == key[9]; then print "9 pressed."; then goto wait
- if $lastKey == key[esc]; then print "Escape pressed. You are finished!"; then goto nextScript
- if $lastKey == key[tab]; then print "Tab pressed."; then goto wait
- if $lastKey == key[back]; then print "Backspace pressed."; then goto wait
- if $lastKey == key[cf4]; then print "Ctrl-F4 pressed."; then goto wait
- if $lastKey == key[f3]; then print "F3 pressed."; then goto wait
- if $lastKey == key[enter]; then print "Enter pressed."; then goto wait
- print "Unknown key pressed! ($lastKey)"
-
-
- #--------------------------------------------------------------------------
- # Nothing new here...
-
- wait:
- print " Press any key..."
- getkey
- goto start
-
-
- #--------------------------------------------------------------------------
- # Check for the next sample script.
-
- nextScript:
- if file[samples/variable.scr]; then script samples/variable.scr
- end
-